/******************************************************************************* 
 * Copyright (C) 2012-2015 Microfountain Technology, Inc. All Rights Reserved. 
 * 
 * Unauthorized copying of this file, via any medium is strictly prohibited.   
 * Proprietary and confidential
 * 
 * Last Modified: 2015-11-25 9:18:14
 ******************************************************************************/
package cn.cmcc.online.smsapi.sdk.dex;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Process;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.File;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import cn.cmcc.online.smsapi.sdk.Iservice.CorpSignInterface;
import cn.cmcc.online.smsapi.sdk.Iservice.IActionService;
import cn.cmcc.online.smsapi.sdk.Iservice.OnlineParseInterface;
import cn.cmcc.online.smsapi.sdk.Iservice.OnlineUpdateCycleConfigInterface;
import cn.cmcc.online.smsapi.sdk.Iservice.ParseBubbleInterface;
import cn.cmcc.online.smsapi.sdk.Iservice.ParseDateInterface;
import cn.cmcc.online.smsapi.sdk.Iservice.XyCallBack;
import cn.cmcc.online.smsapi.sdk.action.AbsSdkDoAction;
import cn.cmcc.online.smsapi.sdk.constant.Constant;
import cn.cmcc.online.smsapi.sdk.db.entity.JarSubInfoManager;
import cn.cmcc.online.smsapi.sdk.db.entity.SysParamEntityManager;
import cn.cmcc.online.smsapi.sdk.log.LogManager;
import cn.cmcc.online.smsapi.sdk.net.NetUtil;
import cn.cmcc.online.smsapi.sdk.net.util.SigntureUtil;
import cn.cmcc.online.smsapi.sdk.queue.SdkTaskQueue;
import cn.cmcc.online.smsapi.sdk.queue.TaskInfo;
import cn.cmcc.online.smsapi.sdk.threadpool.SmartSmsThreadPoolManager;
import cn.cmcc.online.smsapi.sdk.util.ConversationManager;
import cn.cmcc.online.smsapi.sdk.util.CorpSignUtils;
import cn.cmcc.online.smsapi.sdk.util.DuoquUtils;
import cn.cmcc.online.smsapi.sdk.util.FileUtils;
import cn.cmcc.online.smsapi.sdk.util.InitUtil;
import cn.cmcc.online.smsapi.sdk.util.JarSubCheckQueue;
import cn.cmcc.online.smsapi.sdk.util.JsonUtil;
import cn.cmcc.online.smsapi.sdk.util.KeyManager;
import cn.cmcc.online.smsapi.sdk.util.PopupUtil;
import cn.cmcc.online.smsapi.sdk.util.RecordFunctionUtil;
import cn.cmcc.online.smsapi.sdk.util.StringUtils;
import cn.cmcc.online.smsapi.sdk.util.XyUtil;
import cn.cmcc.online.smsapi.util.UUIDUtils;
/*SDK-431 songzhirong 20160530 start*/
/*SDK-481 hewengao 20160613 start */
import dalvik.system.DexClassLoader;
/*SDK-673 hewengao 20161114 end*/
@SuppressLint("NewApi")
public class DexUtil {

	public static final String CLASS_PREFIX = "cn.cmcc.online.smsapi.sdk.Iservice.";
    private static final String TAG = "DexUtil";
    private static ClassLoader mDexClassLoader;
    private static OnlineParseInterface mOnlineParseImpl;
    private static OnlineUpdateCycleConfigInterface mOnlineUpdateCycleConfig;
    /*SDK-640 hewengao 20161012 start*/
    private static Map<String, ClassLoader> mClassLoaderMap = new ConcurrentHashMap<String, ClassLoader>();
    private static Map<String, Class> mClassMap = new ConcurrentHashMap<String, Class>();
    /*SDK-640 hewengao 20161012 end*/
//    public static ExecutorService pool = Executors.newFixedThreadPool(1);
    /* SDK-453/yangzhi/2016.05.23---start--- */
    private static String uiVersion = "";// ui版本号
    /* SDK-453/yangzhi/2016.05.23---end--- */

    /* RM-1351 huangzhiqiang 20170407 start */
    public static boolean mRunNewUploadPubInfoSign = true;
    /* RM-1351 huangzhiqiang 20170407 end */

    public static void init() {
        try {
            final File dexInternalStoragePath = new File(Constant.getJarPath());
            if (dexInternalStoragePath.exists()) {

                if (/* SigntureUtil.verifySignature(Constant.getContext()) */SigntureUtil.getSignResult(Constant.getJarPath())) {
                    mDexClassLoader = getDexClassLoader(true);
                    // OnlineViewImpl = getOnlineViewImpl(true);
                    mOnlineParseImpl = getOnlineParseImpl(true);
                    if (LogManager.debug) {
                        LogManager.i("DexUtil", "验证通过");
                    }

                } else {
                    if (LogManager.debug) {
                        LogManager.i("DexUtil", "验证不通过");
                    }
                }
                
            }

        } catch (Throwable e) {
            LogManager.e("DexUtil", e.getMessage(),e);
        }

    }

    /**
     * 初始化OnlineUpdateCycleConfig对象
     * 
     */
    public static void initOnlineUpdateCycleConfig() {
        mOnlineUpdateCycleConfig = getOnlineUpdateCycleConfig();
        /* SDK-517 huangzhiqiang 20160701 start */
        setOnlineUpdateCycleConfigInstance(null);
        /* SDK-517 huangzhiqiang 20160701 end */
    }
    

    /* SDK-657 zhaojiangwei 20161101 start */
    public synchronized static ClassLoader getDexClassLoader() {
    /* SDK-657 zhaojiangwei 20161101 end */	
        try {
            if (mDexClassLoader == null) {
                final File dexInternalStoragePath = new File(Constant.getJarPath());
                if (dexInternalStoragePath.exists()) {
                    if (/* SigntureUtil.verifySignature(Constant.getContext()) */SigntureUtil.getSignResult(Constant.getJarPath())) {
                        /* RM-1652/yangzhi/2017.06.07---start--- */
                        mDexClassLoader = new DexClassLoader(dexInternalStoragePath.getCanonicalPath(), Constant.getOutDexPath(), null, Constant.getContext().getClassLoader());
                        XyUtil.chmod("640", Constant.getOutDexPath() + File.separator + dexInternalStoragePath.getName().substring(0, dexInternalStoragePath.getName().length() - 4) + ".dex");
                        /* RM-1652/yangzhi/2017.06.07---end--- */
                    }
                }
            }

        } catch (Throwable e) {
//            e.printStackTrace();
            LogManager.e("DexUtil", e.getMessage(),e);
        }
        return mDexClassLoader;
    }
    /* SDK-657 zhaojiangwei 20161101 start */
    public synchronized static ClassLoader getDexClassLoader(boolean reload) {
    /* SDK-657 zhaojiangwei 20161101 end */
        try {
            if (mDexClassLoader == null || reload) {
                final File dexInternalStoragePath = new File(Constant.getJarPath());
                if (dexInternalStoragePath.exists()) {
                    if (/* SigntureUtil.verifySignature(Constant.getContext()) */SigntureUtil.getSignResult(Constant.getJarPath())) {
                        /* RM-1652/yangzhi/2017.06.07---start--- */
                        mDexClassLoader = new DexClassLoader(dexInternalStoragePath.getCanonicalPath(), Constant.getOutDexPath(), null, Constant.getContext().getClassLoader());
                        /* RM-1652/yangzhi/2017.06.07---end--- */
                    }
                }
            }

        } catch (Throwable e) {
            LogManager.e("DexUtil", e.getMessage(),e);
        }
        return mDexClassLoader;
    }

    public static void removeClassLoaderBySubname(String subname) {
        try {
            LogManager.d("JarSubInfo", "removeClassLoaderBySubname subname=", subname);
            mClassLoaderMap.remove(subname + "_ClassLoader");
            mClassMap.remove(subname + "_Class");
        } catch (Throwable e) {
            LogManager.d("DexUtil", e.getMessage());
        }
    }

    public static ClassLoader getClassLoaderBymap(Map<String, String> map, final String subname, boolean reload) {
        try {
        	/*SDK-667 zhaojiangwei 20161108 start*/
            //ClassLoader classLoader = mClassLoaderMap.get(subname + "_ClassLoader");
            ClassLoader classLoader = null;
            if(!reload) {
                classLoader = mClassLoaderMap.get(subname + "_ClassLoader");
            }
            /*SDK-667 zhaojiangwei 20161108 end*/
            if (classLoader != null) {
                return classLoader;
            } else {
                String jarPath = FileUtils.getFilePath(Constant.getPARSE_PATH(), subname + "_", ".jar");
                final File dexInternalStoragePath = new File(jarPath);
                if (dexInternalStoragePath.exists() && SigntureUtil.getSignResult(jarPath)) {

                    // Internal storage where the DexClassLoader writes the
                    // optimized dex file to.
                        // Initialize the class loader with the secondary dex file.
                          /*SDK-654 hewengao 20161019 start*/
                         ClassLoader tempParentLoader = getDexClassLoader();
                        if(tempParentLoader != null) {
                            /* RM-1652/yangzhi/2017.06.07---start--- */
                            classLoader = new DexClassLoader(dexInternalStoragePath.getCanonicalPath(), Constant.getOutDexPath(), null, tempParentLoader);
                            /* RM-1652/yangzhi/2017.06.07---end--- */
                        }
                      //XyUtil.chmod("640", optimizedDexOutputPath.getCanonicalPath() + File.separator + dexInternalStoragePath.getName().substring(0, dexInternalStoragePath.getName().length() - 4) + ".dex");
                        /*SDK-654 hewengao 20161019 end*/
                    if (classLoader != null) {
                        mClassLoaderMap.put(subname + "_ClassLoader", classLoader);
                        return classLoader;
                    }

                }

            }
        } catch (Throwable e) {
            LogManager.e("DexUtil", e.getMessage(),e);
            /* SDK-584 zhaojiangwei 20160906 start */
            DexUtil.saveExceptionLog(e);
            /* SDK-584 zhaojiangwei 20160906 end */
        } finally {
            try {
                /*SDK-616 hewengao 20160912 start*/
                SmartSmsThreadPoolManager.iccidPool.execute(new Runnable() {
                /*SDK-616 hewengao 20160912 end*/
                    @Override
                    public void run() {
                        try {
                              /*SDK-426 hewengao 20160506 start */
                            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
                            Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                            /*SDK-627 hewengao/20160929 start*/
                            Thread.currentThread().setName("xiaoyuan-ipool"+Thread.currentThread().hashCode());
                            /*SDK-627 hewengao/20160929 end*/
                              /*SDK-426 hewengao 20160506 end */
                            if (subname != null && subname.length() > 7) {
                                long time = 0;
                                Long cacheTime = Constant.checkJarMap.get(subname);
                                if (cacheTime != null) {
                                    time = cacheTime;
                                }
                                long addTaskForTime = Constant.addTaskForTime;
                                // mOnlineUpdateCycleConfig不为null时才调用getUpdateCycleByType，防止死循环
                                if (mOnlineUpdateCycleConfig != null) {
                                    addTaskForTime = DexUtil.getUpdateCycleByType(OnlineUpdateCycleConfigInterface.TYPE_JAR_UPDATE_CYCLE, Constant.addTaskForTime);
                                }
                                if (System.currentTimeMillis() >= (time + addTaskForTime)) {
                                    JarSubInfoManager.insertOrUpdateJarSubInfo(subname, "-1", JarSubInfoManager.USED);
                                    Constant.checkJarMap.put(subname, System.currentTimeMillis());
                                    JarSubCheckQueue.runJarSubCheckQueue();
                                }
                            }
                        } catch (Exception e) {
                            LogManager.e(Constant.TAG, "getClassLoaderBymap: ", e);
                            /* SDK-584 zhaojiangwei 20160906 start */
                            DexUtil.saveExceptionLog(e);
                            /* SDK-584 zhaojiangwei 20160906 end */
                        }
                    }
                });
            
            } catch (Throwable e) {
                LogManager.e(Constant.TAG, "getClassLoaderBymap: ", e);

            }
        }
        return null;
    }
    
    /*SDK-667 zhaojiangwei 20161108 start*/
    public static Class getClassBymap(Map<String, String> map, String className) {
        return getClassBymap(map,className,false);
    }
    /*SDK-667 zhaojiangwei 20161108 end*/
    
    public static Class getClassBymap(Map<String, String> map, String className, boolean reLoad) {
        String subname = null;
        try {
            subname = className.substring(className.lastIndexOf(".") + 1);
            ClassLoader classLoader = getClassLoaderBymap(map, subname, reLoad);
            if (classLoader != null) {
            	/*MEIZU-1783 songzhirong 20161213 start*/
            	Class classInstane = null;
            	if(reLoad){
            		classInstane = classLoader.loadClass(className);
                    if (classInstane != null) {
                        mClassMap.put(subname + "_Class", classInstane);
                        return classInstane;
                    }
            	}
                classInstane = mClassMap.get(subname + "_Class");
            	/*MEIZU-1783 songzhirong 20161213 end*/
                if (classInstane != null) {
                    return classInstane;
                } else {
                    classInstane = classLoader.loadClass(className);
                    if (classInstane != null) {
                        mClassMap.put(subname + "_Class", classInstane);

                        return classInstane;
                    }
                }
            }
        } catch (Throwable e) {
            /*SDK-667 hewengao 20161107 start*/
            removeClassLoaderBySubname(subname);
            /*SDK-667 hewengao 20161107 end*/

            /*SDK-699 wangxingjian 20161208 start*/
             /*SDK-674 hewengao 20161114 start*/
            /*MEIZU-2258 songzhirong 20170322 start */
//            DuoquUtils.getSdkDoAction().logInfo(Constant.TAG," error getClassBymap not find className:"+className,null);
            /*MEIZU-2258 songzhirong 20170322 start */
            LogManager.w(Constant.TAG," error getClassBymap not find className:"+className,null);
             /*SDK-674 hewengao 20161114 end*/
            /*SDK-699 wangxingjian 20161208 end*/
            
            LogManager.e("DexUtil", e.getMessage());
            /* SDK-584 zhaojiangwei 20160906 start */
            DexUtil.saveExceptionLog(e);
            /* SDK-584 zhaojiangwei 20160906 end */
        }
        /*SDK-699 wangxingjian 20161208 start*/
         /*SDK-674 hewengao 20161114 start*/
        LogManager.w(Constant.TAG,"getClassBymap not find className:"+className,null);
         /*SDK-674 hewengao 20161114 end*/
        /*SDK-699 wangxingjian 20161208 end*/
        return null;
    }

    /**
     * 是否是应用渠道
     * 
     * @return
     */
    public static boolean isAppChannel(String appKey) {
        return true;
//        if (DuoquUtils.getAidlAction().supportAidlAction()) {
//            return DuoquUtils.getAidlAction().isAppChannel(appKey);
//        }
//        boolean opRet = false;
//        if (StringUtils.isNull(appKey)) {
//            return opRet;
//        }
//        try {
//            OnlineParseInterface lib = DexUtil.getOnlineParseImpl(false);
//            if (lib != null) {
//                opRet = lib.isAppChannel(appKey);
//            }
//        }
//        catch (Throwable e) {
//            LogManager.e(Constant.TAG, "isAppChannel: ", e);
//        }
//        return opRet;
    }
    
    /* SDK-657 zhaojiangwei 20161101 start */
    public synchronized static OnlineParseInterface getOnlineParseImpl(boolean reload) {
    /* SDK-657 zhaojiangwei 20161101 end */
        try {
            if (mOnlineParseImpl == null || reload) {
                ClassLoader dexClassLoader = getDexClassLoader();
                if (dexClassLoader != null) {

                    Class onlineParseImplClass = dexClassLoader.loadClass(CLASS_PREFIX+"OnlineParseImpl");
                    if (onlineParseImplClass != null) {
                        mOnlineParseImpl = (OnlineParseInterface) onlineParseImplClass.newInstance();
                    }

                }

            }
        } catch (Throwable e) {
//            exception.printStackTrace();
            LogManager.w(Constant.TAG, "getOnlineParseImpl: ", e);

        }
        return mOnlineParseImpl;
    }

    public static ParseDateInterface getParseDateImpl(boolean reload) {
        ParseDateInterface parseDate = null;
        try {
            Class parseDateClass = getClassBymap(null, CLASS_PREFIX+"ParseDate");
            if (parseDateClass != null) {
                parseDate = (ParseDateInterface) parseDateClass.newInstance();
            }

        } catch (Throwable e) {
            LogManager.w(Constant.TAG, "getParseDateImpl: ", e);

        }
        return parseDate;

    }
    /*SDK-654 hewengao 20161026 start*/
    static android.util.LruCache<String,Map<String, Object>> mCacheParseResult = new android.util.LruCache<String,Map<String, Object>>(12);
    static long mLastParseTime= 0;
    /*SDK-654 hewengao 20161026 end*/
    public static Map<String, Object> parseMsgToMap(String sender, String content, Map<String, String> map) {
       
        Map<String, Object> valueMap = null;
        try {
            OnlineParseInterface lib = null;
              /*SDK-654 hewengao 20161026 start*/
            final String cacheKey =StringUtils.getMD5(sender+content);
            Map<String, Object> res =  mCacheParseResult.get(cacheKey);
            if(res != null){
                HashMap<String,Object> data = new HashMap<String,Object>();
                data.putAll(res);
                /*SDK-622 hewengao 20161101 start*/
                data.put("from_cache","");
                /*SDK-622 hewengao 20161101 end*/
                return data;
            }
            if(System.currentTimeMillis() - mLastParseTime > 30000){
                mCacheParseResult.evictAll();
            }
              /*SDK-654 hewengao 20161026 end*/
            lib = DexUtil.getOnlineParseImpl(false);

            if (lib != null) {
                valueMap = lib.parseMessage(sender, content, map);
                /*SDK-654 hewengao 20161026 start*/
                mLastParseTime = System.currentTimeMillis();
                if(valueMap != null && valueMap.size() > 2) {
                    HashMap<String,Object> data = new HashMap<String,Object>();
                    data.putAll(valueMap);
                    mCacheParseResult.put(cacheKey, data);
                }
                /*SDK-654 hewengao 20161026 end*/
            }
        } catch (Throwable e) {
            LogManager.w("DexUtil", e.getMessage(),e);
        }
        return valueMap;
    }
    
    /**
     * 兜底验证码优先识别
     * 
     * @param sender
     * @param content
     * @param map
     * @return
     */
    public static Map<String, Object> parseVerifyCodeToMap(String sender, String content, Map<String, String> map) {
        
        Map<String, Object> valueMap = null;
        try {
            OnlineParseInterface lib = DexUtil.getOnlineParseImpl(false);
            if (lib != null) {
                valueMap = lib.parseVerCode(sender, content, map);
            }
        } catch (Throwable e) {
            LogManager.w("DexUtil", e.getMessage(),e);
        }
        return valueMap;
    }

    public static String getSuanfaVersion() {
        OnlineParseInterface lib = null;
        String channelName = null;
        try {
            channelName = SysParamEntityManager.getStringParam(Constant.getContext(), Constant.CHANNEL);
            lib = DexUtil.getOnlineParseImpl(false);
            if (lib != null) {
                String suanfaVersion = lib.getReqVersion(channelName);
                if (!StringUtils.isNull(suanfaVersion)) {
                    return suanfaVersion;
                }
            }
        } catch (Throwable e) {
            LogManager.e("DexUtil getSuanfaVersion", "获取算法包内的版本号出现异常");
        }
        // 无法获取算法包内的算法包版本号时，使用默认方案获取算法包版本号，除联想渠道算法包版本号为20150619外，其它渠道都使用20150202
        if ("VMhlWdEwVNEW_LENOVO".equals(channelName)) {
            return "20150619";
        }
        return Constant.suanfa_version;
    }

    public static Map<String, Object> handerDateValueMap(Map<String, Object> valueMap) {
       
        Map<String, Object> newValueMap = null;
        try {
            ParseDateInterface lib = DexUtil.getParseDateImpl(false);
            if (lib != null) {
                newValueMap = lib.handerValueMap(valueMap);
            } else {
                LogManager.d("showPopuMessage", "ParseDateInterface is null");
            }
        } 
        catch (Throwable e) {
            LogManager.e(Constant.TAG, "handerDateValueMap: " + e.getMessage(), e);
        }
        return newValueMap;

    }

    public static Map<String, Object> handerBubbleValueMap(Map<String, Object> valueMap) {
        
        Map<String, Object> newValueMap = null;
        /*SDK-431 songzhirong 20160530 start*/
        JSONObject jsonObject = null;
        String uuid = UUIDUtils.uniqId();
        try {
            jsonObject = JsonUtil.changeMapToJason(valueMap); 
            ConversationManager.saveLogIn(uuid,"cn.com.xy.sms.sdk.dex.DexUtil", "handerBubbleValueMap",  jsonObject);
            /*SDK-431 songzhirong 20160530 end*/
            Class parseUtilBubbleClass = getClassBymap(null, CLASS_PREFIX+"ParseUtilBubble");
            if (parseUtilBubbleClass != null) {
                ParseBubbleInterface parseUtilBubble = (ParseBubbleInterface) parseUtilBubbleClass.newInstance();
                if (parseUtilBubble != null) {
                    newValueMap = parseUtilBubble.handerValueMap(valueMap);
                    Log.i("handerBubbleValueMap", "newValueMap = " + newValueMap);
                    if (newValueMap != null){
                        SdkTaskQueue.addTask(new TaskInfo(12, "state",  String.valueOf(RecordFunctionUtil.RICH_BUBBLE_STATE)));//丰富气泡功能标记状态
                    }
                }
            }
            
        } catch (Throwable e) {
            LogManager.w(Constant.TAG, "handerBubbleValueMap error" , e);
        }finally{
            /*SDK-431 songzhirong 20160530 start*/
            ConversationManager.saveLogOut(uuid,"cn.com.xy.sms.sdk.dex.DexUtil", "handerBubbleValueMap",  jsonObject,JsonUtil.changeMapToJason(newValueMap));
            /*SDK-431 songzhirong 20160530 end*/
        }
        return newValueMap;

    }
    
    public static boolean isEnterpriseSms(Context ctx, String phoneNumber, String smsContent, Map<String, String> extend) {
       
        OnlineParseInterface lib = null;
        boolean result = false;
        try {

            lib = DexUtil.getOnlineParseImpl(false);
            if (lib != null) {
                result = lib.isEnterpriseSms(ctx, phoneNumber, smsContent, extend);
            }
            else {
                result = PopupUtil.isEnterpriseSms(ctx, phoneNumber, smsContent, extend);
            }
        }
        catch (Throwable e) {
            result = PopupUtil.isEnterpriseSms(ctx, phoneNumber, smsContent, extend);
            return result;
        }
        return result;
    }

    public static int getActionCode(String action) {
        
        int type = -1;
        OnlineParseInterface lib = null;
        try {

            lib = DexUtil.getOnlineParseImpl(false);

            if (lib != null) {
                type = lib.getActionCode(action);
            } else {
                type = PopupUtil.getActionCode(action);
            }

        } catch (Throwable e) {
            LogManager.w("DexUtil", e.getMessage(),e);
            type = PopupUtil.getActionCode(action);
            return type;
        }
        return type;
    }

    /**
     * 是否启用服务选择页
     * 
     * @param channel
     *            客户端渠道号
     * @param type
     *            动作类型
     * @return
     */
    public static int isServiceChoose(String channel, String type) {
        
        int result = -1;
        OnlineParseInterface lib = null;
        try {
            lib = DexUtil.getOnlineParseImpl(false);
            if (lib != null) {
                result = lib.isServiceChoose(channel, type);
            }
        } catch (Throwable e) {
            // TODO: handle exception
            return -2;
        }
        return result;
    }

    /**
     * 获取情景资源版本号
     * 
     * @return
     */
    public static String getSceneVersion() {
        
        String channel = null;
        try {
            // 获取算法包内的资源版本号
            channel = SysParamEntityManager.getStringParam(Constant.getContext(), Constant.CHANNEL);
            OnlineParseInterface lib = DexUtil.getOnlineParseImpl(false);
            if (lib != null) {
                String sceneVersion = lib.getSceneVersion(channel);
                if (!StringUtils.isNull(sceneVersion)) {
                    return sceneVersion;
                }
            }
        } catch (Throwable e) {
            LogManager.w("DexUtil", "getSceneVersion获取算法包内的资源版本号出现异常",e);
        }

        // 无法获取算法包内的资源版本号时，使用默认方案获取资源版本号，除联想渠道资源版本号为20150619外，其它渠道都使用20140815
        if ("VMhlWdEwVNEW_LENOVO".equals(channel)) {
            return "20150619";
        }
        return "20140815";
    }

    /**
     * 根据类型获取更新周期
     * 
     * @param type
     *            类型
     * @param defaultValue
     *            默认值，无法获取数据时返回该值
     * @return
     */
    /* SDK-657 zhaojiangwei 20161101 start */
    public synchronized static long getUpdateCycleByType(int type, long defaultValue) {
    /* SDK-657 zhaojiangwei 20161101 end */
      
        try {
            if (mOnlineUpdateCycleConfig == null) {
                mOnlineUpdateCycleConfig = getOnlineUpdateCycleConfig();
            }
            if (mOnlineUpdateCycleConfig != null) {
                return mOnlineUpdateCycleConfig.getUpdateCycle(type, defaultValue);
            }
        } catch (Throwable t) {
            LogManager.w("xiaoyuan", "DexUtil getUpdateCycleByType：", t);
        }
        return defaultValue;
    }
  
    /**
     * 反射获取OnlineUpdateCycleConfig对象
     * 
     * @return
     */
    private static OnlineUpdateCycleConfigInterface getOnlineUpdateCycleConfig() {
        try {
            Class onlineUpdateCycleConfigClass = getClassBymap(null, CLASS_PREFIX+"OnlineUpdateCycleConfig");
            if (onlineUpdateCycleConfigClass != null) {
                mOnlineUpdateCycleConfig = (OnlineUpdateCycleConfigInterface) onlineUpdateCycleConfigClass.newInstance();
            }
        } catch (Throwable t) {
            LogManager.w("xiaoyuan", "getOnlineUpdateCycleConfig error", t);
        }
        return mOnlineUpdateCycleConfig;
    }

    public static CorpSignInterface getCorpSignImpl(boolean reload) {
        CorpSignInterface corpSign = null;
        try {
            Class corpSignClass = getClassBymap(null, CLASS_PREFIX+"CorpSignImpl");
            if (corpSignClass != null) {
                corpSign = (CorpSignInterface) corpSignClass.newInstance();
            }

        } catch (Throwable e) {
//            exception.printStackTrace();
            LogManager.w(Constant.TAG, "getCorpSignImpl error: ", e);


        }
        return corpSign;

    }
    /* RM-1351 huangzhiqiang 20170407 start */
    /**
     * 获取多个企业签名
     * 
     * @param msg
     * @return
     */
    public static String[] getCorpArr(String msg) {
        if (!mRunNewUploadPubInfoSign) {
            return null;
        }     
        String[] corpArr = null;
        try {
            CorpSignInterface lib = DexUtil.getCorpSignImpl(false);
            if (lib != null) {
                corpArr = lib.getCorpArr(msg);
            }
        } catch (Throwable e) {
            mRunNewUploadPubInfoSign = false;
            LogManager.w(Constant.TAG, "DexUtil getCorpArr error", e);
        }
        return corpArr;
    }
    /* RM-1351 huangzhiqiang 20170407 end */

    /* SDK-478 huangzhiqiang 20160623 start */
    /**
     * 获取企业签名及行业编码
     * 
     * @param msg
     * @return [企业签名,行业编码]
     */
    public static String[] getCorpAndEc(String msg) {        
        String[] corpAndEc = null;
        try {
            CorpSignInterface lib = DexUtil.getCorpSignImpl(false);
            if (lib != null) {
                corpAndEc = lib.getCorpAndEc(msg);
            }
        } catch (Throwable e) {
            LogManager.w(Constant.TAG, "DexUtil getCorpAndEc error: ", e);
        }
        if (corpAndEc == null || corpAndEc.length < 2) {
            corpAndEc = new String[] { getCorp(msg), null };
        }
        return corpAndEc;
    }
    /* SDK-478 huangzhiqiang 20160623 end */
    /**
     * 获取企业签名
     * 
     * @param msg
     * @return
     */
    public static String getCorp(String msg) {
       
        try {
            CorpSignInterface lib = DexUtil.getCorpSignImpl(false);
            if (lib != null) {
                return lib.getCorp(msg);
            } else {
                return CorpSignUtils.getCorp(msg);
            }
        } catch (Throwable e) {
            try {
                return CorpSignUtils.getCorp(msg);
            } catch (Throwable e2) {

            }
        }
        return "";
    }
    
    public static IActionService getActionInterfaceImpl(boolean reload) {
        IActionService actionServiceImpl = null;
        try {
            Class actionServiceClass = getClassBymap(null, CLASS_PREFIX+"ActionServiceImpl");
            if (actionServiceClass != null) {
                actionServiceImpl = (IActionService) actionServiceClass.newInstance();
            }
        } catch (Throwable e) {
            LogManager.w(Constant.TAG, "DexUtil getActionInterfaceImpl ", e);
        }
        return actionServiceImpl;

    }


    /* SDK-517 huangzhiqiang 20160701 start */
    private static Object mOnlineUpdateCycleConfigInstance = null;

    private static Object getOnlineUpdateCycleConfigInstance(Class<?> cls) throws Throwable {
        Object instance = null;
        if (mOnlineUpdateCycleConfigInstance != null) {
            instance = mOnlineUpdateCycleConfigInstance;
        } else if (cls != null) {
            instance = cls.newInstance();
            mOnlineUpdateCycleConfigInstance = instance;
        }
        return instance;
    }

    private static void setOnlineUpdateCycleConfigInstance(Object obj) {
        mOnlineUpdateCycleConfigInstance = obj;
    }
    /* SDK-517 huangzhiqiang 20160701 end */

     /*SDK-392  hewengao 20160416 start*/
     /**
      * 根据类型 获取网络开关
      * @param type  
      * @return
      */
    public static boolean geOnOffByType(int type) {
      
        try {
            Class onlineClass = getClassBymap(null, CLASS_PREFIX+"OnlineUpdateCycleConfig");
            if (onlineClass != null) {
                KeyManager.initAppKey();
                /* SDK-517 huangzhiqiang 20160701 start */
                Object obj = getOnlineUpdateCycleConfigInstance(onlineClass);
                /* SDK-517 huangzhiqiang 20160701 end */
                Method method = onlineClass.getMethod("geOnOffByType", Integer.class, String.class);
                boolean res = (Boolean) method.invoke(obj, type, KeyManager.getAppKey());
                /* SDK-392 songzhirong 20160416 start */
                return res;
                /* SDK-392 songzhirong 20160416 start */
            }
        } catch (Throwable t) {
            LogManager.w("DexUtil", "DexUtil geOnOffByKey error", t);
        }
        return false;
    }
     /*SDK-392  hewengao 20160416 end*/
        
     public static Date convertDate(String dateString) {
     
		Date date = null;
		try {
			ClassLoader dexClassLoader = getDexClassLoader();
			if (dexClassLoader != null) {
				Class cls = dexClassLoader.loadClass(CLASS_PREFIX+"DateTimeNormalizer");
				if (cls != null) {
					Method method = cls.getMethod("convertDate", String.class);
					date = (Date) method.invoke(cls, dateString);
				}
			}
		}
		catch (Throwable t) {
			LogManager.e("DexUtil", "DexUtil convertDate error：", t);
		}
		return date;
     }
     
     /* SDK-601 20160830 zhaojiangwei start */
     public static Date convertDate(String dateString, Date baseDate) {
       
 		Date date = null;
 		try {
 			ClassLoader dexClassLoader = getDexClassLoader();
 			if (dexClassLoader != null) {
 				Class cls = dexClassLoader.loadClass(CLASS_PREFIX+"DateTimeNormalizer");
 				if (cls != null) {
 					Method method = cls.getMethod("convertDate", String.class, Date.class, Boolean.class, Boolean.class);
 					date = (Date) method.invoke(cls, dateString, baseDate, true, false);
 				}
 			}
 		}
 		catch (Throwable t) {
 			LogManager.e("DexUtil", "DexUtil convertDate2 error：", t);
 		}
 		return date;
      }
     /* SDK-601 20160830 zhaojiangwei end */

    /* SDK-638/yangzhi/2016.10.11---start--- */
    public static long convertDateLong(String dateString, Date timeBase, boolean autoFill, boolean ignoreIfNoDate,
            boolean maxThanBaseTime) {
        
        long time = 0L;
        try {
            ClassLoader dexClassLoader = getDexClassLoader();
            if (dexClassLoader != null) {
                Class cls = dexClassLoader.loadClass(CLASS_PREFIX+"DateTimeNormalizer");
                if (cls != null) {
                    Method method = cls.getMethod("convertDateLong", String.class, Date.class, boolean.class,
                            boolean.class, boolean.class);
                    time = (Long) method.invoke(cls, dateString, timeBase, autoFill, ignoreIfNoDate, maxThanBaseTime);
                }
            }
        } catch (Throwable t) {
            LogManager.e("DexUtil", "DexUtil convertDateLong error：", t);
        }
        return time;
    }
    /* SDK-638/yangzhi/2016.10.11---end--- */

     /*SDK-425 lilong 20160510 start*/
     /*SDK-451/yangzhi/2016.05.23---start---*/
    public static JSONArray getConfigByType(int type, String uiversion, Integer suportMenuId) {
     
        try {
            Class onlineClass = getClassBymap(null, CLASS_PREFIX+"OnlineUpdateCycleConfig");
            if (onlineClass != null) {
                KeyManager.initAppKey();
                
                /* SDK-517 huangzhiqiang 20160701 start */
                Object obj = getOnlineUpdateCycleConfigInstance(onlineClass);
                
                /* SDK-517 huangzhiqiang 20160701 end */
                Method method = onlineClass.getMethod("getConfigByType", Integer.class, String.class, String.class,
                        String.class, Integer.class);
                JSONArray data = (JSONArray) method.invoke(obj, type, KeyManager.getAppKey(), NetUtil.APPVERSION,
                        uiversion, suportMenuId);
                

                return data;
            }
        } catch (Throwable t) {
            LogManager.e("DexUtil", "DexUtil geOnOffByKey error" , t);
        }
        return null;
    }
     /*SDK-451/yangzhi/2016.05.23---end---*/
     /*SDK-425 lilong 20160510 end*/
    
    /*SDK-602 zhaojiangwei 20160912 start */
    public static String getOnLineConfigureData(int type) {
       
        try {
            Class onlineClass = getClassBymap(null, CLASS_PREFIX+"OnlineUpdateCycleConfig");
            if (onlineClass != null) {
                Object obj = getOnlineUpdateCycleConfigInstance(onlineClass);
                Method method = onlineClass.getMethod("getConfigureString", Integer.class,Map.class);
                String data = (String) method.invoke(obj, type, null);
                return data;
            }
        }
        catch (Throwable t) {
            LogManager.e("DexUtil", "DexUtil getOnLineConfigureData error", t);
        }
        return null;
    }
    /*SDK-602 zhaojiangwei 20160912 end */

     
     /*SDK-382 /songzhirong/2016.05.17---start---*/
     public static void handleParseMsg(final Context ctx, final String msgId,final String phoneNumber, final String smsCenterNum,
             final String smsContent, final long smsTime, final Map<String, String> extend,final Map<String, Object> result){
             
            try {
//              long start = System.currentTimeMillis();
                final JSONObject jsobj = JsonUtil.changeMapToJason(result); 
//              long end = System.currentTimeMillis();
//              Log.i("handleParseMsg", "time="+(end-start));

                if(jsobj==null) return;
                /*SDK-616 hewengao 20160912 start*/
                SmartSmsThreadPoolManager.dexUtilPool.execute(new Runnable() {
                /*SDK-616 hewengao 20160912 end*/
                    @Override
                    public void run() {
                        try {
                            Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
                            Class parseUtilConversationClass = getClassBymap(null, CLASS_PREFIX+"ParseUtilConversation");
                            if (parseUtilConversationClass != null) {
                                  Method method = parseUtilConversationClass.getMethod("handleParseMsg",Context.class, String.class,String.class, String.class,
                                            String.class, long.class, Map.class,JSONObject.class);
                                  method.invoke(parseUtilConversationClass,  ctx, msgId, phoneNumber,  smsCenterNum,
                                         smsContent,  smsTime,  extend,jsobj);
                                  
                              
                            }  
//                          ParseUtilConversation.handleParseMsg(ctx, msgId,phoneNumber, smsCenterNum, smsContent, smsTime, extend, jsobj);
                        } catch (Throwable e) {
//                          e.printStackTrace();
                            LogManager.e(Constant.TAG, "handleParseMsg: error", e);
                        }
                        
                        
                    }
                });
                    
                    
            } catch (Throwable e) {
//              e.printStackTrace();
                LogManager.e(Constant.TAG, "handleParseMsg: error", e);
            }
     }
        
     
    public static JSONObject queryConversationMsg(Context ctx,
            String actionType, JSONObject data, Map extend) {
        try {

            
            Class parseUtilConversationClass = getClassBymap(null,
                    CLASS_PREFIX+"ParseUtilConversationHelper");
            if (parseUtilConversationClass != null) {
                Method method = parseUtilConversationClass
                        .getMethod("queryConversationMsg", Context.class,String.class, JSONObject.class, Map.class);
                return (JSONObject) method.invoke(parseUtilConversationClass,ctx, actionType,data,extend);
            }
             
//          return ParseUtilConversationHelper.queryConversationMsg(ctx, actionType,
//                  data, extend);

        } catch (Throwable e) {
            LogManager.e(Constant.TAG,
                    "queryConversationMsg: error", e);

        }
        return null;
    }
      /*SDK-382 /songzhirong/2016.05.17---end---*/

    /* SDK-453/yangzhi/2016.05.23---start--- */
    public static String getUIVersion() {
        try {
            if (StringUtils.isNull(uiVersion)) {
                /* SDK-477/yangzhi/2016.06.07---start---*/
               
                /*SDK-481 hewengao 20160613 start */
                String UIConfigClass = DuoquUtils.getSdkDoAction().getConfig(AbsSdkDoAction.CONFIG_UI_CONFIG_CLASS, null);
                Class cls = Class.forName(UIConfigClass);
                //Class cls = Class.forName("cn.com.xy.sms.sdk.ui.config.UIConfig");
                /*SDK-481 hewengao 20160613 end */
                
                /* SDK-477/yangzhi/2016.06.07---end---*/
                Method m = cls.getMethod("getUIVersion");
                if (m != null) {
                    uiVersion = (String) m.invoke(cls);
                }
            }
        } catch (Throwable e) {
            // e.printStackTrace();
            uiVersion = "-1";
            LogManager.e(Constant.TAG, "getUIVersion: ", e);
        }
        return uiVersion;
    }
    /*SDK-453/yangzhi/2016.05.23---end---*/

    /*SDK-457 hewengao 20160525 start */
    public static void beforeInitBigJar(){
      
        try{
            FileUtils.loadPUJarFile();
            /*SDK-475 hewengao 20160615 start */
             String clsArr0[] ={"ScenesScanner","ParseSimpleBubbleUtil","ParseNotification"};
             String clsName = CLASS_PREFIX+"";
             for(String cls : clsArr0){
                 DexUtil.getClassBymap(null, clsName+cls);
             }
             for (int i =1; i <= 21; i++) {
                 DexUtil.getClassBymap(null, clsName+"PU"+ (i < 10 ? "0"+i:i));
             }
             /*SDK-475 hewengao 20160615 end */
             /*SDK-594 hewengao 20160615 start */
             DuoquUtils.getSdkDoAction().onEventCallback(AbsSdkDoAction.SDK_EVENT_LOAD_COMPLETE, null);
             /*SDK-594 hewengao 20160615 end */
             
             /*SDK-747 zhaojiangwei 20160330 start */
             JarSubCheckQueue.mSDKLoadCompleted = true;
             /*SDK-747 zhaojiangwei 20160330 end */
             
        }catch(Throwable e){
             LogManager.e(Constant.TAG, "beforeInitBigJar: ", e);
        }finally {
            /*SDK-673 hewengao 20161114 start*/
            InitUtil.isLoadedBigJar =true;
            /*SDK-673 hewengao 20161114 start*/
        }
    }
    /*SDK-457 hewengao 20160525 end */
     /* SDK-421 huangzhiqiang 20160525 start */
     /**
      * 短信原文去敏
      * 
      * @param msg 短信原文
      * @return
      */
    public static String multiReplace(String msg) {       
        try {
            Class<?> parseUtilMultipleClass = getClassBymap(null, CLASS_PREFIX+"ParseUtilMultiple");
            if (parseUtilMultipleClass != null) {
                Method method = parseUtilMultipleClass.getMethod("multiReplace", String.class);
                return (String) method.invoke(parseUtilMultipleClass, msg);
            }
        } catch (Throwable e) {
            LogManager.e(Constant.TAG, "DexUtil multiReplace: ", e);
        }
        return null;
    }
    /**
     * 分片数据识别
     * 
     * @param msg 去敏后的短信原文
     * @param msgIdx 分组小标
     * @param msgMd 模数
     * @return index0:需要上传的字符序列  index1:短信是否结束标示  null:分片失败
     */
    public static String[] parseShard(String msg, String msgIdx, String msgMd) {       
        try {
            Class<?> parseUtilMultipleClass = getClassBymap(null, CLASS_PREFIX+"ParseUtilMultiple");
            if (parseUtilMultipleClass != null) {
                Method method = parseUtilMultipleClass.getMethod("check", String.class, String.class, String.class);
                return (String[]) method.invoke(parseUtilMultipleClass, msg, msgIdx, msgMd);
            }
        } catch (Throwable e) {
            LogManager.e(Constant.TAG, "DexUtil parseShard: ", e);
        }
        return null;
    }
     /* SDK-421 huangzhiqiang 20160525 end */
    
    /*SDK-431  /songzhirong/2016.05.23---start---*/
    public static void saveLogIn(final String uuid,final String className, final String methodName, final Object... args) {
      
        try { 
            /*SDK-616 hewengao 20160912 start*/
            SmartSmsThreadPoolManager.dexUtilPool.execute(new Runnable() {
            /*SDK-616 hewengao 20160912 start*/
                @Override
                public void run() {
                    try {
                        Class cls = getClassBymap(null, CLASS_PREFIX+"LogService");
                        if (cls != null) {
                            Method method = cls.getMethod("saveLogIn",String.class, String.class, String.class, Object[].class);
                            method.invoke(cls, uuid,className, methodName, handlerParamsToJSONObjectIfNeed(args));
                        }
//                         LogService.saveLogIn(uuid,className, methodName, args);

                    } catch (Throwable e) {
                        // TODO: handle exception
                    }
                    
                }
            });
          
            // LogService.saveLogIn(className, methodName, args);
        } catch (Throwable t) {
            LogManager.e("DexUtil", "DexUtil saveLogIn：", t);
        }
    }

    public static void saveLogOut(final String uuid,final String className, final String methodName, final Object... args) {
       
        try {
            /*SDK-616 hewengao 20160912 start*/
            SmartSmsThreadPoolManager.dexUtilPool.execute(new Runnable() {
            /*SDK-616 hewengao 20160912 end*/
                @Override
                public void run() {
                   try {
                       Class cls = getClassBymap(null, CLASS_PREFIX+"LogService");
                       if (cls != null) {
                           Method method = cls.getMethod("saveLogOut", String.class,String.class, String.class, Object[].class);
                           method.invoke(cls, uuid,className, methodName, handlerParamsToJSONObjectIfNeed(args));
                       }
//                     LogService.saveLogOut(uuid,className, methodName, args);

                   } catch (Throwable e) {
                    // TODO: handle exception
                   }
                    
                }
            });
           
            // LogService.saveLogOut(className, methodName, args);
        } catch (Throwable t) {
            LogManager.e("DexUtil", "DexUtil saveLogOut：", t);
        }
    }
    
    /* SDK-584 zhaojiangwei 20160905 start */
    public static void saveExceptionLog(final Throwable ecx) {
       
        try {
            /* SDK-616 hewengao 20160912 start */
            SmartSmsThreadPoolManager.dexUtilPool.execute(new Runnable() {
                /* SDK-616 hewengao 20160912 start */
                @Override
				public void run() {
					try {
						String className = "";
						String methordName = "";
						StackTraceElement[] stackTrace = ecx.getStackTrace();
						if (stackTrace!=null && stackTrace.length>0) {
							className = stackTrace[0].getClassName();
							methordName = stackTrace[0].getMethodName();
						}
						Class cls = getClassBymap(null, CLASS_PREFIX+"LogService");
						if (cls != null) {
							Method method = cls.getMethod("saveLogException", String.class, String.class,
									Throwable.class);
							method.invoke(cls, className, methordName, ecx);
						}
					}
					catch (Throwable e) {
						LogManager.e("DexUtil", "DexUtil execute：", e);
					}
				}
			});
		}
		catch (Throwable e) {
			// TODO: handle exception
			LogManager.e("DexUtil", "DexUtil saveExceptionLog：", e);
		}
	}
	/* SDK-584 zhaojiangwei 20160905 end */

    /* SDK-515 huangzhiqiang 20160629 start */
    /**
     * 处理方法参数，将不是java原生类型的参数转换为JSONObject对象
     * 
     * @param params
     * @return
     */
    public static Object[] handlerParamsToJSONObjectIfNeed(Object[] params) {
        if (params == null || params.length == 0) {
            return null;
        }
        try {
            for (int i = 0; i < params.length; i++) {
                Object param = params[i];
                if (param == null) {
                    continue;
                }
                if (param instanceof XyCallBack || param instanceof Context
                        || param.getClass().getName().startsWith("android.")) {
                    params[i] = new JSONObject().put("objectToJson", true).put("className", param.getClass().getName());
                } else if (param.getClass().getName().startsWith("cn.com.xy.sms")) {
                    JSONObject objJson = JsonUtil.parseObjectToJson(param);
                    if (objJson != null) {
                        params[i] = objJson;
                    }
                }
            }
        } catch (Throwable e) {
            LogManager.e("DexUtil", "DexUtil handlerParamsToJSONObjectIfNeed：", e);
        }
        return params;
    }
    /* SDK-515 huangzhiqiang 20160629 end */

   public static void insertLog(String tableName,String sql,JSONObject valuesObject){  
       
       try {
           Class cls = getClassBymap(null,CLASS_PREFIX+"LogService");
           if (cls != null) {
               Method method = cls.getMethod("insert", String.class,String.class,JSONObject.class);
               method.invoke(cls,tableName, sql,valuesObject);
           }         
//         LogService.insert(tableName, sql, valuesObject);
       } catch (Throwable t) {
           LogManager.e("DexUtil", "DexUtil saveLogOut：", t);
       }       
   }
   
   public static void deleteLog(String tableName,String sql,JSONObject whereArgs){
       
       try {
           Class cls = getClassBymap(null,CLASS_PREFIX+"LogService");
           if (cls != null) {
               Method method = cls.getMethod("delete", String.class,String.class,JSONObject.class);
               method.invoke(cls,tableName, sql,whereArgs);
           }           
//         LogService.delete(tableName, sql, whereArgs);
       } catch (Throwable t) {
           LogManager.e("DexUtil", "DexUtil saveLogOut：", t);
       }   
       
   }
   
   public static JSONArray queryLog(String tableName,
           String sql,String[] columns, JSONObject whereArgs,String orderBy, String limit){
      
       try {
           Class cls = getClassBymap(null,CLASS_PREFIX+"LogService");
           if (cls != null) {
               Method method = cls.getMethod("query", String.class,String.class,String[].class,
                       JSONObject.class,String.class,String.class);
               return (JSONArray)method.invoke(cls, tableName, 
                        sql, columns,whereArgs, orderBy,  limit);
           }          
//         return LogService.query(tableName,  sql, columns, whereArgs, orderBy, limit);
       } catch (Throwable t) {
           LogManager.e("DexUtil", "DexUtil saveLogOut：", t);
       }   
       return null;
   }
    
   
   public static String queryLog(Integer type,String channel,String appVersion){
       
       try {
         Class cls = getClassBymap(null,CLASS_PREFIX+"LogService");
           if (cls != null) {
               Method method = cls.getMethod("queryLog", Integer.class,String.class,String.class);
               return (String)method.invoke(cls, type,channel, appVersion);
           }   
//           return LogService.queryLog(type, channel,appVersion);//     
       } catch (Throwable t) {
           LogManager.e("DexUtil", "DexUtil queryLog：", t);
       }   
       return "";
   }
   
   public static void postCallback(Integer type,String postData){
     
       try {
               Class cls = getClassBymap(null,CLASS_PREFIX+"LogService");
               if (cls != null) {
                   Method method = cls.getMethod("postCallback", Integer.class,String.class);
                   method.invoke(cls, type,postData);
               }
//               LogService.postCallback(type, postData);
           } catch (Throwable t) {
               LogManager.e("DexUtil", "DexUtil postCallback：", t);
           }   
           
   }
 
   /*SDK-431  /songzhirong/2016.05.23---end---*/

    /* SDK-428 huangzhiqiang 20160603 start */
    
    public static Object methodInvoke(String className, String methodName, Class<?>[] parameterTypes, Object[] args)
            throws Throwable {
        Object result = null;
        Class<?> receiver = getClassBymap(null, className);
        if (receiver != null) {
            Method method = receiver.getMethod(methodName, parameterTypes);
            return method.invoke(receiver, args);
        }
        return result;
    }
    /* SDK-571 huangzhiqiang 20160729 end */
    /* SMARTISAN-65 huangzhiqiang 20160630 start */
    public static void putActionDataToDataSource(JSONObject dataSource, Map<String, Object> baseParseResult,
            Map<String, Object> extend) {
        try {
            if (dataSource == null || baseParseResult == null || !baseParseResult.containsKey("NEW_ADACTION")) {
                return;
            }
            Class<?> cls = getClassBymap(null, CLASS_PREFIX+"WizardServiceMenuData");
            if (cls != null) {
                Method method = cls.getMethod("putActionDataToDataSource", JSONObject.class,
                        Map.class, Map.class);
                method.invoke(cls, dataSource, baseParseResult, extend);
            } else {
                localPutActionDataToDataSource(dataSource, baseParseResult, extend);
            }
        } catch (Throwable t) {
            localPutActionDataToDataSource(dataSource, baseParseResult, extend);
            LogManager.w(Constant.TAG, "DexUtil putActionDataToDataSource error:", t);
        }
    }

    private static void localPutActionDataToDataSource(JSONObject dataSource, Map<String, Object> baseParseResult,
            Map<String, Object> extend) {
        try {
            dataSource.put("NEW_ADACTION", baseParseResult.get("NEW_ADACTION"));
        } catch (Throwable t) {
            LogManager.w(Constant.TAG, "DexUtil localPutActionDataToDataSource error:", t);
        }
    }
    /* SMARTISAN-65 huangzhiqiang 20160630 end */
	
}
